package domain;

import java.util.HashSet;
import java.util.Set;

public class ContactGroup {
	private long groupId;
	private String groupName;
	private Set<Contact> contacts = new HashSet<Contact>();
	
	public ContactGroup() {
	}
	
	public Set<Contact> getContacts() {
		return contacts;
	}

	public void setContacts(Set<Contact> contacts) {
		this.contacts = contacts;
	}

	public long getGroupId() {
		return this.groupId;
	}

	public void setGroupId(long groupId) {
		this.groupId = groupId;
	}

	public String getGroupName() {
		return groupName;
	}

	public void setGroupName(String groupName) {
		this.groupName = groupName;
	}
	
	public void addContact(Contact contact){
		this.contacts.add(contact);
		if (!contact.getGroups().contains(this)) {
			contact.addGroup(this);
		}
	}
	
	public void removeContact(Contact contact){
		this.contacts.remove(contact);
		if (contact.getGroups().contains(this)) {
			contact.removeGroup(this);
		}
	}
	
}
